//通用函数
import axios from 'axios'
import Vue from 'vue'

axios.defaults.baseURL = "http://127.0.0.1:5000"

//跨组件传值
export let bus = new Vue()

//获取时间格式
export let getYYYYMMDD = datestr => {
    let time = new Date(datestr);
    return time.getFullYear() + "-" + fillzero(time.getMonth() + 1) + "-" + fillzero(time.getDate());
}


// 根据日期对象 获取yyyy-mm-dd hh:mm:ss 格式数据
export let getYYYYMMDD_HHMMSS = date => {
    return date.getFullYear() + "-" + fillzero(date.getMonth() + 1) + "-" + fillzero(date.getDate()) + ' ' + fillzero(date.getHours()) + ':' + fillzero(date.getMinutes()) + ':' + fillzero(date.getSeconds());
}

// 小于10补0
export let fillzero = num => num < 10 ? '0' + num : num

export default axios